package com.xunshibao.mis.user.action;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class LoginController {
    @RequestMapping(value="/login")
    public @ResponseBody Map<String, Object> login(@RequestParam(value="username")String username, @RequestParam(value="password")String password) {
        Map<String, Object> json = new HashMap<String, Object>();
        if("haiker".equals(username) && "123".equals(password)) {
            json.put("success", true);
        } else {
            json.put("msg", "用户名密码错误");
        }
        return json;
    }
    
    @RequestMapping(value="/j_logout")
    public @ResponseBody Map<String, Object> logout(HttpSession session) {
        Map<String, Object> json = new HashMap<String, Object>();
        session.invalidate();
        json.put("status", true);
        return json;
    }
}
